const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const webpackPath = require("./webpack.path.js")

module.exports = {
    entry: path.join(webpackPath.srcRendererPath, "index.tsx"),
    output: {
        filename: 'renderer.js',
        path: webpackPath.distPath,
        clean: true,
    },
    mode: 'production',
    target: ['web', 'electron-renderer'],
    plugins: [
        new HtmlWebpackPlugin({
            template: path.join(webpackPath.rootPath, "public", "index.html"),
            minify: {
                collapseWhitespace: true,
                removeAttributeQuotes: true,
                removeComments: true,
            },
            isBrowser: false,
            isDevelopment: false,
        }),
    ],
    module: {
        rules: [
            {
                test: /\.(js|jsx|ts|tsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env', '@babel/preset-react','@babel/preset-typescript'],
                    },
                },
            },
        ],
    },
    resolve: {
        extensions: ['.js', '.tsx', '.ts', '.jsx'],
    },
}